<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>class Vector - matrix: Ruby Standard Library Documentation</title>


<script src="./js/navigation.js" defer></script>
<script src="./js/search.js" defer></script>
<script src="./js/search_index.js" defer></script>
<script src="./js/searcher.js" defer></script>
<script src="./js/darkfish.js" defer></script>

<script src="./js/jquery-3.2.0.min.js"></script>

<script src="./js/vue.min.js"></script>
<script src="./js/js.cookie.min.js"></script>

<link href="./css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="./css/rdoc.css" rel="stylesheet">
<link href="./css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "./";
  var index_rel_prefix = "./";
  var darkModeCsseHref = "./css/rdoc-dm.css"
  var defaultModeCssHref = "./css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="class">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0.preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="./index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="./table_of_contents.html#pages">Pages</a>
    <a href="./table_of_contents.html#classes">Classes</a>
    <a href="./table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    

    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
<div id="parent-class-section" class="nav-section">
  <h3>Parent</h3>

  <p class="link">Object
</div>

        
<div id="includes-section" class="nav-section">
  <h3>Included Modules</h3>

  <ul class="link-list">
    <li><a class="include" href="ExceptionForMatrix.html">ExceptionForMatrix</a>
    <li><span class="include">Enumerable</span>
  </ul>
</div>

        
<div id="extends-section" class="nav-section">
  <h3>Extended With Modules</h3>

  <ul class="link-list">
    <li><span class="extend">Matrix::ConversionHelper</span>
  </ul>
</div>

        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li ><a href="#method-c-5B-5D">::[]</a>
    <li ><a href="#method-c-basis">::basis</a>
    <li ><a href="#method-c-elements">::elements</a>
    <li ><a href="#method-c-independent-3F">::independent?</a>
    <li ><a href="#method-c-new">::new</a>
    <li ><a href="#method-c-zero">::zero</a>
    <li ><a href="#method-i-2A">#*</a>
    <li ><a href="#method-i-2B">#+</a>
    <li ><a href="#method-i-2B-40">#+@</a>
    <li ><a href="#method-i-2D">#-</a>
    <li ><a href="#method-i-2D-40">#-@</a>
    <li ><a href="#method-i-2F">#/</a>
    <li ><a href="#method-i-3D-3D">#==</a>
    <li ><a href="#method-i-5B-5D">#[]</a>
    <li ><a href="#method-i-5B-5D-3D">#[]=</a>
    <li ><a href="#method-i-angle_with">#angle_with</a>
    <li ><a href="#method-i-coerce">#coerce</a>
    <li ><a href="#method-i-collect">#collect</a>
    <li ><a href="#method-i-collect-21">#collect!</a>
    <li ><a href="#method-i-collect2">#collect2</a>
    <li ><a href="#method-i-component">#component</a>
    <li ><a href="#method-i-covector">#covector</a>
    <li ><a href="#method-i-cross">#cross</a>
    <li ><a href="#method-i-cross_product">#cross_product</a>
    <li ><a href="#method-i-dot">#dot</a>
    <li ><a href="#method-i-each">#each</a>
    <li ><a href="#method-i-each2">#each2</a>
    <li ><a href="#method-i-element">#element</a>
    <li ><a href="#method-i-elements_to_f">#elements_to_f</a>
    <li ><a href="#method-i-elements_to_i">#elements_to_i</a>
    <li ><a href="#method-i-elements_to_r">#elements_to_r</a>
    <li ><a href="#method-i-eql-3F">#eql?</a>
    <li class="calls-super" ><a href="#method-i-freeze">#freeze</a>
    <li ><a href="#method-i-hash">#hash</a>
    <li ><a href="#method-i-independent-3F">#independent?</a>
    <li class="calls-super" ><a href="#method-i-initialize_copy">#initialize_copy</a>
    <li ><a href="#method-i-inner_product">#inner_product</a>
    <li ><a href="#method-i-inspect">#inspect</a>
    <li ><a href="#method-i-magnitude">#magnitude</a>
    <li ><a href="#method-i-map">#map</a>
    <li ><a href="#method-i-map-21">#map!</a>
    <li ><a href="#method-i-map2">#map2</a>
    <li ><a href="#method-i-norm">#norm</a>
    <li ><a href="#method-i-normalize">#normalize</a>
    <li ><a href="#method-i-r">#r</a>
    <li ><a href="#method-i-round">#round</a>
    <li ><a href="#method-i-set_component">#set_component</a>
    <li ><a href="#method-i-set_element">#set_element</a>
    <li ><a href="#method-i-set_range">#set_range</a>
    <li ><a href="#method-i-set_value">#set_value</a>
    <li ><a href="#method-i-size">#size</a>
    <li ><a href="#method-i-to_a">#to_a</a>
    <li ><a href="#method-i-to_matrix">#to_matrix</a>
    <li ><a href="#method-i-to_s">#to_s</a>
    <li ><a href="#method-i-zero-3F">#zero?</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="class-Vector">
    <h1 id="class-Vector" class="class">
      class Vector
    </h1>

    <section class="description">
    
<p>The <code>Vector</code> class represents a mathematical vector, which is useful in its own right, and also constitutes a row or column of a <a href="Matrix.html"><code>Matrix</code></a>.</p>

<h2 id="class-Vector-label-Method+Catalogue">Method Catalogue<span><a href="#class-Vector-label-Method+Catalogue">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>To create a Vector:</p>
<ul><li>
<p><a href="Vector.html#method-c-5B-5D"><code>Vector.[](*array)</code></a></p>
</li><li>
<p><a href="Vector.html#method-c-elements"><code>Vector.elements</code></a>(array, copy = true)</p>
</li><li>
<p><a href="Vector.html#method-c-basis"><code>Vector.basis</code></a>(size: n, index: k)</p>
</li><li>
<p><a href="Vector.html#method-c-zero"><code>Vector.zero(n)</code></a></p>
</li></ul>

<p>To access elements:</p>
<ul><li>
<p><a href="Vector.html#method-i-5B-5D"><code>[](i)</code></a></p>
</li></ul>

<p>To set elements:</p>
<ul><li>
<p><a href="Vector.html#method-i-5B-5D-3D"><code>[]=</code></a>(i, v)</p>
</li></ul>

<p>To enumerate the elements:</p>
<ul><li>
<p><a href="Vector.html#method-i-each2"><code>each2(v)</code></a></p>
</li><li>
<p><a href="Vector.html#method-i-collect2"><code>collect2(v)</code></a></p>
</li></ul>

<p>Properties of vectors:</p>
<ul><li>
<p><a href="Vector.html#method-i-angle_with"><code>angle_with(v)</code></a></p>
</li><li>
<p><a href="Vector.html#method-c-independent-3F"><code>Vector.independent?(*vs)</code></a></p>
</li><li>
<p><a href="Vector.html#method-i-independent-3F"><code>independent?(*vs)</code></a></p>
</li><li>
<p><a href="Vector.html#method-i-zero-3F"><code>zero?</code></a></p>
</li></ul>

<p><a href="Vector.html"><code>Vector</code></a> arithmetic:</p>
<ul><li>
<p><a href="Vector.html#method-i-2A"><code>*(x)</code></a> “is matrix or number”</p>
</li><li>
<p><a href="Vector.html#method-i-2B"><code>+(v)</code></a></p>
</li><li>
<p><a href="Vector.html#method-i-2D"><code>-(v)</code></a></p>
</li><li>
<p>#/(v)</p>
</li><li>
<p><a href="Vector.html#method-i-2B-40"><code>+@</code></a></p>
</li><li>
<p><a href="Vector.html#method-i-2D-40"><code>-@</code></a></p>
</li></ul>

<p><a href="Vector.html"><code>Vector</code></a> functions:</p>
<ul><li>
<p><a href="Vector.html#method-i-inner_product"><code>inner_product(v)</code></a>, <a href="Vector.html#method-i-dot"><code>dot(v)</code></a></p>
</li><li>
<p><a href="Vector.html#method-i-cross_product"><code>cross_product(v)</code></a>, <a href="Vector.html#method-i-cross"><code>cross(v)</code></a></p>
</li><li>
<p><a href="Vector.html#method-i-collect"><code>collect</code></a></p>
</li><li>
<p><a href="Vector.html#method-i-collect-21"><code>collect!</code></a></p>
</li><li>
<p><a href="Vector.html#method-i-magnitude"><code>magnitude</code></a></p>
</li><li>
<p><a href="Vector.html#method-i-map"><code>map</code></a></p>
</li><li>
<p><a href="Vector.html#method-i-map-21"><code>map!</code></a></p>
</li><li>
<p><a href="Vector.html#method-i-map2"><code>map2(v)</code></a></p>
</li><li>
<p><a href="Vector.html#method-i-norm"><code>norm</code></a></p>
</li><li>
<p><a href="Vector.html#method-i-normalize"><code>normalize</code></a></p>
</li><li>
<p><a href="Vector.html#method-i-r"><code>r</code></a></p>
</li><li>
<p><a href="Vector.html#method-i-round"><code>round</code></a></p>
</li><li>
<p><a href="Vector.html#method-i-size"><code>size</code></a></p>
</li></ul>

<p>Conversion to other data types:</p>
<ul><li>
<p><a href="Vector.html#method-i-covector"><code>covector</code></a></p>
</li><li>
<p><a href="Vector.html#method-i-to_a"><code>to_a</code></a></p>
</li><li>
<p><a href="Vector.html#method-i-coerce"><code>coerce(other)</code></a></p>
</li></ul>

<p>String representations:</p>
<ul><li>
<p><a href="Vector.html#method-i-to_s"><code>to_s</code></a></p>
</li><li>
<p><a href="Vector.html#method-i-inspect"><code>inspect</code></a></p>
</li></ul>

    </section>

      <section id="5Buntitled-5D" class="documentation-section">



        <section class="attribute-method-details" class="method-section">
        <header>
        <h3>Attributes</h3>
        </header>

          <div id="attribute-i-elements" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">elements</span><span
                class="attribute-access-type">[R]</span>
            </div>

            <div class="method-description">
              <p>INSTANCE CREATION</p>
              </div>
            </div>
            </section>


                <section id="public-class-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Class Methods</h3>
                </header>

                  <div id="method-c-5B-5D" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">[]</span><span
                                class="method-args">(*array)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Creates a <a href="Vector.html"><code>Vector</code></a> from a list of elements.</p>

<pre>Vector[7, 4, ...]</pre>

                              <div class="method-source-code" id="5B-5D-source">
            <pre><span class="ruby-comment"># File matrix-0.4.2/lib/matrix.rb, line 1981</span>
<span class="ruby-keyword">def</span> <span class="ruby-constant">Vector</span>.<span class="ruby-identifier ruby-title">[]</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">array</span>)
  <span class="ruby-identifier">new</span> <span class="ruby-identifier">convert_to_array</span>(<span class="ruby-identifier">array</span>, <span class="ruby-keyword">false</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-basis" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">basis</span><span
                                class="method-args">(size:, index:)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns a standard basis <code>n</code>-vector, where k is the index.</p>

<pre class="ruby"><span class="ruby-constant">Vector</span>.<span class="ruby-identifier">basis</span>(<span class="ruby-value">size:</span>, <span class="ruby-value">index:</span>) <span class="ruby-comment"># =&gt; Vector[0, 1, 0]</span>
</pre>

                              <div class="method-source-code" id="basis-source">
            <pre><span class="ruby-comment"># File matrix-0.4.2/lib/matrix.rb, line 1998</span>
<span class="ruby-keyword">def</span> <span class="ruby-constant">Vector</span>.<span class="ruby-identifier ruby-title">basis</span>(<span class="ruby-value">size:</span>, <span class="ruby-value">index:</span>)
  <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">&quot;invalid size (#{size} for 1..)&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">size</span> <span class="ruby-operator">&lt;</span> <span class="ruby-value">1</span>
  <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">&quot;invalid index (#{index} for 0...#{size})&quot;</span> <span class="ruby-keyword">unless</span> <span class="ruby-value">0</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-identifier">index</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">index</span> <span class="ruby-operator">&lt;</span> <span class="ruby-identifier">size</span>
  <span class="ruby-identifier">array</span> = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">size</span>, <span class="ruby-value">0</span>)
  <span class="ruby-identifier">array</span>[<span class="ruby-identifier">index</span>] = <span class="ruby-value">1</span>
  <span class="ruby-identifier">new</span> <span class="ruby-identifier">convert_to_array</span>(<span class="ruby-identifier">array</span>, <span class="ruby-keyword">false</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-elements" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">elements</span><span
                                class="method-args">(array, copy = true)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Creates a vector from an Array.  The optional second argument specifies whether the array itself or a copy is used internally.</p>

                              <div class="method-source-code" id="elements-source">
            <pre><span class="ruby-comment"># File matrix-0.4.2/lib/matrix.rb, line 1989</span>
<span class="ruby-keyword">def</span> <span class="ruby-constant">Vector</span>.<span class="ruby-identifier ruby-title">elements</span>(<span class="ruby-identifier">array</span>, <span class="ruby-identifier">copy</span> = <span class="ruby-keyword">true</span>)
  <span class="ruby-identifier">new</span> <span class="ruby-identifier">convert_to_array</span>(<span class="ruby-identifier">array</span>, <span class="ruby-identifier">copy</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-independent-3F" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">independent?</span><span
                                class="method-args">(*vs)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns whether all of vectors are linearly independent.</p>

<pre class="ruby"><span class="ruby-constant">Vector</span>.<span class="ruby-identifier">independent?</span>(<span class="ruby-constant">Vector</span>[<span class="ruby-value">1</span>,<span class="ruby-value">0</span>], <span class="ruby-constant">Vector</span>[<span class="ruby-value">0</span>,<span class="ruby-value">1</span>])
<span class="ruby-comment">#  =&gt; true</span>

<span class="ruby-constant">Vector</span>.<span class="ruby-identifier">independent?</span>(<span class="ruby-constant">Vector</span>[<span class="ruby-value">1</span>,<span class="ruby-value">2</span>], <span class="ruby-constant">Vector</span>[<span class="ruby-value">2</span>,<span class="ruby-value">4</span>])
<span class="ruby-comment">#  =&gt; false</span>
</pre>

                              <div class="method-source-code" id="independent-3F-source">
            <pre><span class="ruby-comment"># File matrix-0.4.2/lib/matrix.rb, line 2145</span>
<span class="ruby-keyword">def</span> <span class="ruby-constant">Vector</span>.<span class="ruby-identifier ruby-title">independent?</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">vs</span>)
  <span class="ruby-identifier">vs</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">TypeError</span>, <span class="ruby-node">&quot;expected Vector, got #{v.class}&quot;</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">v</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Vector</span>)
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">ErrDimensionMismatch</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">v</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">vs</span>.<span class="ruby-identifier">first</span>.<span class="ruby-identifier">size</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">false</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">vs</span>.<span class="ruby-identifier">count</span> <span class="ruby-operator">&gt;</span> <span class="ruby-identifier">vs</span>.<span class="ruby-identifier">first</span>.<span class="ruby-identifier">size</span>
  <span class="ruby-constant">Matrix</span>[<span class="ruby-operator">*</span><span class="ruby-identifier">vs</span>].<span class="ruby-identifier">rank</span>.<span class="ruby-identifier">eql?</span>(<span class="ruby-identifier">vs</span>.<span class="ruby-identifier">count</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-new" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">new</span><span
                                class="method-args">(array)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p><a href="Vector.html#method-c-new"><code>Vector.new</code></a> is private; use Vector[] or <a href="Vector.html#method-c-elements"><code>Vector.elements</code></a> to create.</p>

                              <div class="method-source-code" id="new-source">
            <pre><span class="ruby-comment"># File matrix-0.4.2/lib/matrix.rb, line 2020</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>(<span class="ruby-identifier">array</span>)
  <span class="ruby-comment"># No checking is done at this point.</span>
  <span class="ruby-ivar">@elements</span> = <span class="ruby-identifier">array</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-zero" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">zero</span><span
                                class="method-args">(size)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Return a zero vector.</p>

<pre class="ruby"><span class="ruby-constant">Vector</span>.<span class="ruby-identifier">zero</span>(<span class="ruby-value">3</span>) <span class="ruby-comment"># =&gt; Vector[0, 0, 0]</span>
</pre>

                              <div class="method-source-code" id="zero-source">
            <pre><span class="ruby-comment"># File matrix-0.4.2/lib/matrix.rb, line 2011</span>
<span class="ruby-keyword">def</span> <span class="ruby-constant">Vector</span>.<span class="ruby-identifier ruby-title">zero</span>(<span class="ruby-identifier">size</span>)
  <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">&quot;invalid size (#{size} for 0..)&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">size</span> <span class="ruby-operator">&lt;</span> <span class="ruby-value">0</span>
  <span class="ruby-identifier">array</span> = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">size</span>, <span class="ruby-value">0</span>)
  <span class="ruby-identifier">new</span> <span class="ruby-identifier">convert_to_array</span>(<span class="ruby-identifier">array</span>, <span class="ruby-keyword">false</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Instance Methods</h3>
                </header>

                  <div id="method-i-2A" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">*</span><span
                                class="method-args">(x)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Multiplies the vector by <code>x</code>, where <code>x</code> is a number or a matrix.</p>

                              <div class="method-source-code" id="2A-source">
            <pre><span class="ruby-comment"># File matrix-0.4.2/lib/matrix.rb, line 2222</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">*</span>(<span class="ruby-identifier">x</span>)
  <span class="ruby-keyword">case</span> <span class="ruby-identifier">x</span>
  <span class="ruby-keyword">when</span> <span class="ruby-constant">Numeric</span>
    <span class="ruby-identifier">els</span> = <span class="ruby-ivar">@elements</span>.<span class="ruby-identifier">collect</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span> <span class="ruby-identifier">e</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">x</span>}
    <span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">elements</span>(<span class="ruby-identifier">els</span>, <span class="ruby-keyword">false</span>)
  <span class="ruby-keyword">when</span> <span class="ruby-constant">Matrix</span>
    <span class="ruby-constant">Matrix</span>.<span class="ruby-identifier">column_vector</span>(<span class="ruby-keyword">self</span>) <span class="ruby-operator">*</span> <span class="ruby-identifier">x</span>
  <span class="ruby-keyword">when</span> <span class="ruby-constant">Vector</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">ErrOperationNotDefined</span>, [<span class="ruby-string">&quot;*&quot;</span>, <span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span>, <span class="ruby-identifier">x</span>.<span class="ruby-identifier">class</span>]
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">apply_through_coercion</span>(<span class="ruby-identifier">x</span>, <span class="ruby-identifier">__method__</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-2B" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">+</span><span
                                class="method-args">(v)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p><a href="Vector.html"><code>Vector</code></a> addition.</p>

                              <div class="method-source-code" id="2B-source">
            <pre><span class="ruby-comment"># File matrix-0.4.2/lib/matrix.rb, line 2239</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">+</span>(<span class="ruby-identifier">v</span>)
  <span class="ruby-keyword">case</span> <span class="ruby-identifier">v</span>
  <span class="ruby-keyword">when</span> <span class="ruby-constant">Vector</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">ErrDimensionMismatch</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">size</span> <span class="ruby-operator">!=</span> <span class="ruby-identifier">v</span>.<span class="ruby-identifier">size</span>
    <span class="ruby-identifier">els</span> = <span class="ruby-identifier">collect2</span>(<span class="ruby-identifier">v</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">v1</span>, <span class="ruby-identifier">v2</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">v1</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">v2</span>
    }
    <span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">elements</span>(<span class="ruby-identifier">els</span>, <span class="ruby-keyword">false</span>)
  <span class="ruby-keyword">when</span> <span class="ruby-constant">Matrix</span>
    <span class="ruby-constant">Matrix</span>.<span class="ruby-identifier">column_vector</span>(<span class="ruby-keyword">self</span>) <span class="ruby-operator">+</span> <span class="ruby-identifier">v</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">apply_through_coercion</span>(<span class="ruby-identifier">v</span>, <span class="ruby-identifier">__method__</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-2B-40" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">+@</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="2B-40-source">
            <pre><span class="ruby-comment"># File matrix-0.4.2/lib/matrix.rb, line 2287</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">+@</span>
  <span class="ruby-keyword">self</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-2D" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">-</span><span
                                class="method-args">(v)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p><a href="Vector.html"><code>Vector</code></a> subtraction.</p>

                              <div class="method-source-code" id="2D-source">
            <pre><span class="ruby-comment"># File matrix-0.4.2/lib/matrix.rb, line 2257</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">-</span>(<span class="ruby-identifier">v</span>)
  <span class="ruby-keyword">case</span> <span class="ruby-identifier">v</span>
  <span class="ruby-keyword">when</span> <span class="ruby-constant">Vector</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">ErrDimensionMismatch</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">size</span> <span class="ruby-operator">!=</span> <span class="ruby-identifier">v</span>.<span class="ruby-identifier">size</span>
    <span class="ruby-identifier">els</span> = <span class="ruby-identifier">collect2</span>(<span class="ruby-identifier">v</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">v1</span>, <span class="ruby-identifier">v2</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">v1</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">v2</span>
    }
    <span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">elements</span>(<span class="ruby-identifier">els</span>, <span class="ruby-keyword">false</span>)
  <span class="ruby-keyword">when</span> <span class="ruby-constant">Matrix</span>
    <span class="ruby-constant">Matrix</span>.<span class="ruby-identifier">column_vector</span>(<span class="ruby-keyword">self</span>) <span class="ruby-operator">-</span> <span class="ruby-identifier">v</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">apply_through_coercion</span>(<span class="ruby-identifier">v</span>, <span class="ruby-identifier">__method__</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-2D-40" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">-@</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="2D-40-source">
            <pre><span class="ruby-comment"># File matrix-0.4.2/lib/matrix.rb, line 2291</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">-@</span>
  <span class="ruby-identifier">collect</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span> <span class="ruby-operator">-</span><span class="ruby-identifier">e</span> }
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-2F" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">/</span><span
                                class="method-args">(x)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p><a href="Vector.html"><code>Vector</code></a> division.</p>

                              <div class="method-source-code" id="2F-source">
            <pre><span class="ruby-comment"># File matrix-0.4.2/lib/matrix.rb, line 2275</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">/</span>(<span class="ruby-identifier">x</span>)
  <span class="ruby-keyword">case</span> <span class="ruby-identifier">x</span>
  <span class="ruby-keyword">when</span> <span class="ruby-constant">Numeric</span>
    <span class="ruby-identifier">els</span> = <span class="ruby-ivar">@elements</span>.<span class="ruby-identifier">collect</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span> <span class="ruby-identifier">e</span> <span class="ruby-operator">/</span> <span class="ruby-identifier">x</span>}
    <span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">elements</span>(<span class="ruby-identifier">els</span>, <span class="ruby-keyword">false</span>)
  <span class="ruby-keyword">when</span> <span class="ruby-constant">Matrix</span>, <span class="ruby-constant">Vector</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">ErrOperationNotDefined</span>, [<span class="ruby-string">&quot;/&quot;</span>, <span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span>, <span class="ruby-identifier">x</span>.<span class="ruby-identifier">class</span>]
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">apply_through_coercion</span>(<span class="ruby-identifier">x</span>, <span class="ruby-identifier">__method__</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-3D-3D" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">==</span><span
                                class="method-args">(other)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns whether the two vectors have the same elements in the same order.</p>

                              <div class="method-source-code" id="3D-3D-source">
            <pre><span class="ruby-comment"># File matrix-0.4.2/lib/matrix.rb, line 2198</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">==</span>(<span class="ruby-identifier">other</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">false</span> <span class="ruby-keyword">unless</span> <span class="ruby-constant">Vector</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">other</span>
  <span class="ruby-ivar">@elements</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">other</span>.<span class="ruby-identifier">elements</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-5B-5D" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          vector[range]
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          vector[integer]
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Returns element or elements of the vector.</p>

                              <div class="method-source-code" id="5B-5D-source">
            <pre><span class="ruby-comment"># File matrix-0.4.2/lib/matrix.rb, line 2034</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">[]</span>(<span class="ruby-identifier">i</span>)
  <span class="ruby-ivar">@elements</span>[<span class="ruby-identifier">i</span>]
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="Vector.html#method-i-element">element</a>, <a href="Vector.html#method-i-component">component</a>
                            </div>

                          </div>

                  <div id="method-i-5B-5D-3D" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          vector[range] = new_vector
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          vector[range] = row_matrix
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          vector[range] = new_element
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          vector[integer] = new_element
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Set element or elements of vector.</p>

                              <div class="method-source-code" id="5B-5D-3D-source">
            <pre><span class="ruby-comment"># File matrix-0.4.2/lib/matrix.rb, line 2049</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">[]=</span>(<span class="ruby-identifier">i</span>, <span class="ruby-identifier">v</span>)
  <span class="ruby-identifier">raise</span> <span class="ruby-constant">FrozenError</span>, <span class="ruby-string">&quot;can&#39;t modify frozen Vector&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">frozen?</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">i</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Range</span>)
    <span class="ruby-identifier">range</span> = <span class="ruby-constant">Matrix</span><span class="ruby-operator">::</span><span class="ruby-constant">CoercionHelper</span>.<span class="ruby-identifier">check_range</span>(<span class="ruby-identifier">i</span>, <span class="ruby-identifier">size</span>, <span class="ruby-value">:vector</span>)
    <span class="ruby-identifier">set_range</span>(<span class="ruby-identifier">range</span>, <span class="ruby-identifier">v</span>)
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">index</span> = <span class="ruby-constant">Matrix</span><span class="ruby-operator">::</span><span class="ruby-constant">CoercionHelper</span>.<span class="ruby-identifier">check_int</span>(<span class="ruby-identifier">i</span>, <span class="ruby-identifier">size</span>, <span class="ruby-value">:index</span>)
    <span class="ruby-identifier">set_value</span>(<span class="ruby-identifier">index</span>, <span class="ruby-identifier">v</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="Vector.html#method-i-set_element">set_element</a>, <a href="Vector.html#method-i-set_component">set_component</a>
                            </div>

                          </div>

                  <div id="method-i-angle_with" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">angle_with</span><span
                                class="method-args">(v)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns an angle with another vector. Result is within the [0..Math::PI].</p>

<pre class="ruby"><span class="ruby-constant">Vector</span>[<span class="ruby-value">1</span>,<span class="ruby-value">0</span>].<span class="ruby-identifier">angle_with</span>(<span class="ruby-constant">Vector</span>[<span class="ruby-value">0</span>,<span class="ruby-value">1</span>])
<span class="ruby-comment"># =&gt; Math::PI / 2</span>
</pre>

                              <div class="method-source-code" id="angle_with-source">
            <pre><span class="ruby-comment"># File matrix-0.4.2/lib/matrix.rb, line 2407</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">angle_with</span>(<span class="ruby-identifier">v</span>)
  <span class="ruby-identifier">raise</span> <span class="ruby-constant">TypeError</span>, <span class="ruby-node">&quot;Expected a Vector, got a #{v.class}&quot;</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">v</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Vector</span>)
  <span class="ruby-identifier">raise</span> <span class="ruby-constant">ErrDimensionMismatch</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">size</span> <span class="ruby-operator">!=</span> <span class="ruby-identifier">v</span>.<span class="ruby-identifier">size</span>
  <span class="ruby-identifier">prod</span> = <span class="ruby-identifier">magnitude</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">v</span>.<span class="ruby-identifier">magnitude</span>
  <span class="ruby-identifier">raise</span> <span class="ruby-constant">ZeroVectorError</span>, <span class="ruby-string">&quot;Can&#39;t get angle of zero vector&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">prod</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
  <span class="ruby-identifier">dot</span> = <span class="ruby-identifier">inner_product</span>(<span class="ruby-identifier">v</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">dot</span>.<span class="ruby-identifier">abs</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-identifier">prod</span>
    <span class="ruby-identifier">dot</span>.<span class="ruby-identifier">positive?</span> <span class="ruby-operator">?</span> <span class="ruby-value">0</span> <span class="ruby-operator">:</span> <span class="ruby-constant">Math</span><span class="ruby-operator">::</span><span class="ruby-constant">PI</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-constant">Math</span>.<span class="ruby-identifier">acos</span>(<span class="ruby-identifier">dot</span> <span class="ruby-operator">/</span> <span class="ruby-identifier">prod</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-coerce" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">coerce</span><span
                                class="method-args">(other)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>The coerce method provides support for Ruby type coercion. This coercion mechanism is used by Ruby to handle mixed-type numeric operations: it is intended to find a compatible common type between the two operands of the operator. See also Numeric#coerce.</p>

                              <div class="method-source-code" id="coerce-source">
            <pre><span class="ruby-comment"># File matrix-0.4.2/lib/matrix.rb, line 2467</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">coerce</span>(<span class="ruby-identifier">other</span>)
  <span class="ruby-keyword">case</span> <span class="ruby-identifier">other</span>
  <span class="ruby-keyword">when</span> <span class="ruby-constant">Numeric</span>
    <span class="ruby-keyword">return</span> <span class="ruby-constant">Matrix</span><span class="ruby-operator">::</span><span class="ruby-constant">Scalar</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">other</span>), <span class="ruby-keyword">self</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">TypeError</span>, <span class="ruby-node">&quot;#{self.class} can&#39;t be coerced into #{other.class}&quot;</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-collect" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">collect</span><span
                                class="method-args">() { |e| ... }</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Like Array#collect.</p>

                              <div class="method-source-code" id="collect-source">
            <pre><span class="ruby-comment"># File matrix-0.4.2/lib/matrix.rb, line 2351</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">collect</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>) <span class="ruby-comment"># :yield: e</span>
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">to_enum</span>(<span class="ruby-value">:collect</span>) <span class="ruby-keyword">unless</span> <span class="ruby-identifier">block_given?</span>
  <span class="ruby-identifier">els</span> = <span class="ruby-ivar">@elements</span>.<span class="ruby-identifier">collect</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">elements</span>(<span class="ruby-identifier">els</span>, <span class="ruby-keyword">false</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="Vector.html#method-i-map">map</a>
                            </div>

                          </div>

                  <div id="method-i-collect-21" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">collect!</span><span
                                class="method-args">(&amp;block)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Like Array#collect!</p>

                              <div class="method-source-code" id="collect-21-source">
            <pre><span class="ruby-comment"># File matrix-0.4.2/lib/matrix.rb, line 2361</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">collect!</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">to_enum</span>(<span class="ruby-value">:collect!</span>) <span class="ruby-keyword">unless</span> <span class="ruby-identifier">block_given?</span>
  <span class="ruby-identifier">raise</span> <span class="ruby-constant">FrozenError</span>, <span class="ruby-string">&quot;can&#39;t modify frozen Vector&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">frozen?</span>
  <span class="ruby-ivar">@elements</span>.<span class="ruby-identifier">collect!</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
  <span class="ruby-keyword">self</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="Vector.html#method-i-map-21">map!</a>
                            </div>

                          </div>

                  <div id="method-i-collect2" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">collect2</span><span
                                class="method-args">(v) { |e1, e2| ... }</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Collects (as in Enumerable#collect) over the elements of this vector and <code>v</code> in conjunction.</p>

                              <div class="method-source-code" id="collect2-source">
            <pre><span class="ruby-comment"># File matrix-0.4.2/lib/matrix.rb, line 2123</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">collect2</span>(<span class="ruby-identifier">v</span>) <span class="ruby-comment"># :yield: e1, e2</span>
  <span class="ruby-identifier">raise</span> <span class="ruby-constant">TypeError</span>, <span class="ruby-string">&quot;Integer is not like Vector&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">v</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">Integer</span>)
  <span class="ruby-identifier">raise</span> <span class="ruby-constant">ErrDimensionMismatch</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">size</span> <span class="ruby-operator">!=</span> <span class="ruby-identifier">v</span>.<span class="ruby-identifier">size</span>
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">to_enum</span>(<span class="ruby-value">:collect2</span>, <span class="ruby-identifier">v</span>) <span class="ruby-keyword">unless</span> <span class="ruby-identifier">block_given?</span>
  <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">size</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">yield</span> <span class="ruby-ivar">@elements</span>[<span class="ruby-identifier">i</span>], <span class="ruby-identifier">v</span>[<span class="ruby-identifier">i</span>]
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-component" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">component</span><span
                                class="method-args">(i)</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="Vector.html#method-i-5B-5D">[]</a>
                            </div>
                          </div>

                  <div id="method-i-covector" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">covector</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Creates a single-row matrix from this vector.</p>

                              <div class="method-source-code" id="covector-source">
            <pre><span class="ruby-comment"># File matrix-0.4.2/lib/matrix.rb, line 2427</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">covector</span>
  <span class="ruby-constant">Matrix</span>.<span class="ruby-identifier">row_vector</span>(<span class="ruby-keyword">self</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-cross" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">cross</span><span
                                class="method-args">(*vs)</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="Vector.html#method-i-cross_product">cross_product</a>
                            </div>
                          </div>

                  <div id="method-i-cross_product" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">cross_product</span><span
                                class="method-args">(*vs)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the cross product of this vector with the others.</p>

<pre class="ruby"><span class="ruby-constant">Vector</span>[<span class="ruby-value">1</span>, <span class="ruby-value">0</span>, <span class="ruby-value">0</span>].<span class="ruby-identifier">cross_product</span> <span class="ruby-constant">Vector</span>[<span class="ruby-value">0</span>, <span class="ruby-value">1</span>, <span class="ruby-value">0</span>]  <span class="ruby-comment"># =&gt; Vector[0, 0, 1]</span>
</pre>

<p>It is generalized to other dimensions to return a vector perpendicular to the arguments.</p>

<pre class="ruby"><span class="ruby-constant">Vector</span>[<span class="ruby-value">1</span>, <span class="ruby-value">2</span>].<span class="ruby-identifier">cross_product</span> <span class="ruby-comment"># =&gt; Vector[-2, 1]</span>
<span class="ruby-constant">Vector</span>[<span class="ruby-value">1</span>, <span class="ruby-value">0</span>, <span class="ruby-value">0</span>, <span class="ruby-value">0</span>].<span class="ruby-identifier">cross_product</span>(
   <span class="ruby-constant">Vector</span>[<span class="ruby-value">0</span>, <span class="ruby-value">1</span>, <span class="ruby-value">0</span>, <span class="ruby-value">0</span>],
   <span class="ruby-constant">Vector</span>[<span class="ruby-value">0</span>, <span class="ruby-value">0</span>, <span class="ruby-value">1</span>, <span class="ruby-value">0</span>]
)  <span class="ruby-comment">#=&gt; Vector[0, 0, 0, 1]</span>
</pre>

                              <div class="method-source-code" id="cross_product-source">
            <pre><span class="ruby-comment"># File matrix-0.4.2/lib/matrix.rb, line 2326</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">cross_product</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">vs</span>)
  <span class="ruby-identifier">raise</span> <span class="ruby-constant">ErrOperationNotDefined</span>, <span class="ruby-node">&quot;cross product is not defined on vectors of dimension #{size}&quot;</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">size</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-value">2</span>
  <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">&quot;wrong number of arguments (#{vs.size} for #{size - 2})&quot;</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">vs</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">size</span> <span class="ruby-operator">-</span> <span class="ruby-value">2</span>
  <span class="ruby-identifier">vs</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">TypeError</span>, <span class="ruby-node">&quot;expected Vector, got #{v.class}&quot;</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">v</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">Vector</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">ErrDimensionMismatch</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">v</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">size</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">case</span> <span class="ruby-identifier">size</span>
  <span class="ruby-keyword">when</span> <span class="ruby-value">2</span>
    <span class="ruby-constant">Vector</span>[<span class="ruby-operator">-</span><span class="ruby-ivar">@elements</span>[<span class="ruby-value">1</span>], <span class="ruby-ivar">@elements</span>[<span class="ruby-value">0</span>]]
  <span class="ruby-keyword">when</span> <span class="ruby-value">3</span>
    <span class="ruby-identifier">v</span> = <span class="ruby-identifier">vs</span>[<span class="ruby-value">0</span>]
    <span class="ruby-constant">Vector</span>[ <span class="ruby-identifier">v</span>[<span class="ruby-value">2</span>]<span class="ruby-operator">*</span><span class="ruby-ivar">@elements</span>[<span class="ruby-value">1</span>] <span class="ruby-operator">-</span> <span class="ruby-identifier">v</span>[<span class="ruby-value">1</span>]<span class="ruby-operator">*</span><span class="ruby-ivar">@elements</span>[<span class="ruby-value">2</span>],
      <span class="ruby-identifier">v</span>[<span class="ruby-value">0</span>]<span class="ruby-operator">*</span><span class="ruby-ivar">@elements</span>[<span class="ruby-value">2</span>] <span class="ruby-operator">-</span> <span class="ruby-identifier">v</span>[<span class="ruby-value">2</span>]<span class="ruby-operator">*</span><span class="ruby-ivar">@elements</span>[<span class="ruby-value">0</span>],
      <span class="ruby-identifier">v</span>[<span class="ruby-value">1</span>]<span class="ruby-operator">*</span><span class="ruby-ivar">@elements</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">-</span> <span class="ruby-identifier">v</span>[<span class="ruby-value">0</span>]<span class="ruby-operator">*</span><span class="ruby-ivar">@elements</span>[<span class="ruby-value">1</span>] ]
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">rows</span> = <span class="ruby-keyword">self</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">vs</span>, <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">size</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span> <span class="ruby-constant">Vector</span>.<span class="ruby-identifier">basis</span>(<span class="ruby-value">size:</span> <span class="ruby-identifier">size</span>, <span class="ruby-value">index:</span> <span class="ruby-identifier">i</span>) }
    <span class="ruby-constant">Matrix</span>.<span class="ruby-identifier">rows</span>(<span class="ruby-identifier">rows</span>).<span class="ruby-identifier">laplace_expansion</span>(<span class="ruby-value">row:</span> <span class="ruby-identifier">size</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="Vector.html#method-i-cross">cross</a>
                            </div>

                          </div>

                  <div id="method-i-dot" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">dot</span><span
                                class="method-args">(v)</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="Vector.html#method-i-inner_product">inner_product</a>
                            </div>
                          </div>

                  <div id="method-i-each" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">each</span><span
                                class="method-args">(&amp;block)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Iterate over the elements of this vector</p>

                              <div class="method-source-code" id="each-source">
            <pre><span class="ruby-comment"># File matrix-0.4.2/lib/matrix.rb, line 2100</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">each</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">to_enum</span>(<span class="ruby-value">:each</span>) <span class="ruby-keyword">unless</span> <span class="ruby-identifier">block_given?</span>
  <span class="ruby-ivar">@elements</span>.<span class="ruby-identifier">each</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
  <span class="ruby-keyword">self</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-each2" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">each2</span><span
                                class="method-args">(v) { |e1, e2| ... }</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Iterate over the elements of this vector and <code>v</code> in conjunction.</p>

                              <div class="method-source-code" id="each2-source">
            <pre><span class="ruby-comment"># File matrix-0.4.2/lib/matrix.rb, line 2109</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">each2</span>(<span class="ruby-identifier">v</span>) <span class="ruby-comment"># :yield: e1, e2</span>
  <span class="ruby-identifier">raise</span> <span class="ruby-constant">TypeError</span>, <span class="ruby-string">&quot;Integer is not like Vector&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">v</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">Integer</span>)
  <span class="ruby-identifier">raise</span> <span class="ruby-constant">ErrDimensionMismatch</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">size</span> <span class="ruby-operator">!=</span> <span class="ruby-identifier">v</span>.<span class="ruby-identifier">size</span>
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">to_enum</span>(<span class="ruby-value">:each2</span>, <span class="ruby-identifier">v</span>) <span class="ruby-keyword">unless</span> <span class="ruby-identifier">block_given?</span>
  <span class="ruby-identifier">size</span>.<span class="ruby-identifier">times</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">yield</span> <span class="ruby-ivar">@elements</span>[<span class="ruby-identifier">i</span>], <span class="ruby-identifier">v</span>[<span class="ruby-identifier">i</span>]
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">self</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-element" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">element</span><span
                                class="method-args">(i)</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="Vector.html#method-i-5B-5D">[]</a>
                            </div>
                          </div>

                  <div id="method-i-elements_to_f" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">elements_to_f</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="elements_to_f-source">
            <pre><span class="ruby-comment"># File matrix-0.4.2/lib/matrix.rb, line 2445</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">elements_to_f</span>
  <span class="ruby-identifier">warn</span> <span class="ruby-string">&quot;Vector#elements_to_f is deprecated&quot;</span>, <span class="ruby-value">uplevel:</span> <span class="ruby-value">1</span>
  <span class="ruby-identifier">map</span>(<span class="ruby-operator">&amp;</span><span class="ruby-value">:to_f</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-elements_to_i" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">elements_to_i</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="elements_to_i-source">
            <pre><span class="ruby-comment"># File matrix-0.4.2/lib/matrix.rb, line 2450</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">elements_to_i</span>
  <span class="ruby-identifier">warn</span> <span class="ruby-string">&quot;Vector#elements_to_i is deprecated&quot;</span>, <span class="ruby-value">uplevel:</span> <span class="ruby-value">1</span>
  <span class="ruby-identifier">map</span>(<span class="ruby-operator">&amp;</span><span class="ruby-value">:to_i</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-elements_to_r" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">elements_to_r</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="elements_to_r-source">
            <pre><span class="ruby-comment"># File matrix-0.4.2/lib/matrix.rb, line 2455</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">elements_to_r</span>
  <span class="ruby-identifier">warn</span> <span class="ruby-string">&quot;Vector#elements_to_r is deprecated&quot;</span>, <span class="ruby-value">uplevel:</span> <span class="ruby-value">1</span>
  <span class="ruby-identifier">map</span>(<span class="ruby-operator">&amp;</span><span class="ruby-value">:to_r</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-eql-3F" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">eql?</span><span
                                class="method-args">(other)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="eql-3F-source">
            <pre><span class="ruby-comment"># File matrix-0.4.2/lib/matrix.rb, line 2203</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">eql?</span>(<span class="ruby-identifier">other</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">false</span> <span class="ruby-keyword">unless</span> <span class="ruby-constant">Vector</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">other</span>
  <span class="ruby-ivar">@elements</span>.<span class="ruby-identifier">eql?</span> <span class="ruby-identifier">other</span>.<span class="ruby-identifier">elements</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-freeze" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">freeze</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Makes the matrix frozen and Ractor-shareable</p>
                                <div class="method-calls-super">
                                  Calls superclass method
                                  
                              </div>

                              <div class="method-source-code" id="freeze-source">
            <pre><span class="ruby-comment"># File matrix-0.4.2/lib/matrix.rb, line 2177</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">freeze</span>
  <span class="ruby-ivar">@elements</span>.<span class="ruby-identifier">freeze</span>
  <span class="ruby-keyword">super</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-hash" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">hash</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns a hash-code for the vector.</p>

                              <div class="method-source-code" id="hash-source">
            <pre><span class="ruby-comment"># File matrix-0.4.2/lib/matrix.rb, line 2211</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">hash</span>
  <span class="ruby-ivar">@elements</span>.<span class="ruby-identifier">hash</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-independent-3F" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">independent?</span><span
                                class="method-args">(*vs)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns whether all of vectors are linearly independent.</p>

<pre class="ruby"><span class="ruby-constant">Vector</span>[<span class="ruby-value">1</span>,<span class="ruby-value">0</span>].<span class="ruby-identifier">independent?</span>(<span class="ruby-constant">Vector</span>[<span class="ruby-value">0</span>,<span class="ruby-value">1</span>])
<span class="ruby-comment"># =&gt; true</span>

<span class="ruby-constant">Vector</span>[<span class="ruby-value">1</span>,<span class="ruby-value">2</span>].<span class="ruby-identifier">independent?</span>(<span class="ruby-constant">Vector</span>[<span class="ruby-value">2</span>,<span class="ruby-value">4</span>])
<span class="ruby-comment"># =&gt; false</span>
</pre>

                              <div class="method-source-code" id="independent-3F-source">
            <pre><span class="ruby-comment"># File matrix-0.4.2/lib/matrix.rb, line 2163</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">independent?</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">vs</span>)
  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">independent?</span>(<span class="ruby-keyword">self</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">vs</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-inner_product" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">inner_product</span><span
                                class="method-args">(v)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the inner product of this vector with the other.</p>

<pre class="ruby"><span class="ruby-constant">Vector</span>[<span class="ruby-value">4</span>,<span class="ruby-value">7</span>].<span class="ruby-identifier">inner_product</span> <span class="ruby-constant">Vector</span>[<span class="ruby-value">10</span>,<span class="ruby-value">1</span>] <span class="ruby-comment"># =&gt; 47</span>
</pre>

                              <div class="method-source-code" id="inner_product-source">
            <pre><span class="ruby-comment"># File matrix-0.4.2/lib/matrix.rb, line 2303</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">inner_product</span>(<span class="ruby-identifier">v</span>)
  <span class="ruby-identifier">raise</span> <span class="ruby-constant">ErrDimensionMismatch</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">size</span> <span class="ruby-operator">!=</span> <span class="ruby-identifier">v</span>.<span class="ruby-identifier">size</span>

  <span class="ruby-identifier">p</span> = <span class="ruby-value">0</span>
  <span class="ruby-identifier">each2</span>(<span class="ruby-identifier">v</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">v1</span>, <span class="ruby-identifier">v2</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">p</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">v1</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">v2</span>.<span class="ruby-identifier">conj</span>
  }
  <span class="ruby-identifier">p</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="Vector.html#method-i-dot">dot</a>
                            </div>

                          </div>

                  <div id="method-i-inspect" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">inspect</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Overrides Object#inspect</p>

                              <div class="method-source-code" id="inspect-source">
            <pre><span class="ruby-comment"># File matrix-0.4.2/lib/matrix.rb, line 2490</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">inspect</span>
  <span class="ruby-string">&quot;Vector&quot;</span> <span class="ruby-operator">+</span> <span class="ruby-ivar">@elements</span>.<span class="ruby-identifier">inspect</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-magnitude" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">magnitude</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the modulus (Pythagorean distance) of the vector.</p>

<pre class="ruby"><span class="ruby-constant">Vector</span>[<span class="ruby-value">5</span>,<span class="ruby-value">8</span>,<span class="ruby-value">2</span>].<span class="ruby-identifier">r</span> <span class="ruby-comment"># =&gt; 9.643650761</span>
</pre>

                              <div class="method-source-code" id="magnitude-source">
            <pre><span class="ruby-comment"># File matrix-0.4.2/lib/matrix.rb, line 2373</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">magnitude</span>
  <span class="ruby-constant">Math</span>.<span class="ruby-identifier">sqrt</span>(<span class="ruby-ivar">@elements</span>.<span class="ruby-identifier">inject</span>(<span class="ruby-value">0</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">v</span>, <span class="ruby-identifier">e</span><span class="ruby-operator">|</span> <span class="ruby-identifier">v</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">abs2</span>})
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="Vector.html#method-i-r">r</a>, <a href="Vector.html#method-i-norm">norm</a>
                            </div>

                          </div>

                  <div id="method-i-map" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">map</span><span
                                class="method-args">()</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="Vector.html#method-i-collect">collect</a>
                            </div>
                          </div>

                  <div id="method-i-map-21" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">map!</span><span
                                class="method-args">(&amp;block)</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="Vector.html#method-i-collect-21">collect!</a>
                            </div>
                          </div>

                  <div id="method-i-map2" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">map2</span><span
                                class="method-args">(v) { |e1, e2| ... }</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Like <a href="Vector.html#method-i-collect2"><code>Vector#collect2</code></a>, but returns a <a href="Vector.html"><code>Vector</code></a> instead of an Array.</p>

                              <div class="method-source-code" id="map2-source">
            <pre><span class="ruby-comment"># File matrix-0.4.2/lib/matrix.rb, line 2382</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">map2</span>(<span class="ruby-identifier">v</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>) <span class="ruby-comment"># :yield: e1, e2</span>
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">to_enum</span>(<span class="ruby-value">:map2</span>, <span class="ruby-identifier">v</span>) <span class="ruby-keyword">unless</span> <span class="ruby-identifier">block_given?</span>
  <span class="ruby-identifier">els</span> = <span class="ruby-identifier">collect2</span>(<span class="ruby-identifier">v</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">elements</span>(<span class="ruby-identifier">els</span>, <span class="ruby-keyword">false</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-norm" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">norm</span><span
                                class="method-args">()</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="Vector.html#method-i-magnitude">magnitude</a>
                            </div>
                          </div>

                  <div id="method-i-normalize" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">normalize</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns a new vector with the same direction but with norm 1.</p>

<pre class="ruby"><span class="ruby-identifier">v</span> = <span class="ruby-constant">Vector</span>[<span class="ruby-value">5</span>,<span class="ruby-value">8</span>,<span class="ruby-value">2</span>].<span class="ruby-identifier">normalize</span>
<span class="ruby-comment"># =&gt; Vector[0.5184758473652127, 0.8295613557843402, 0.20739033894608505]</span>
<span class="ruby-identifier">v</span>.<span class="ruby-identifier">norm</span> <span class="ruby-comment"># =&gt; 1.0</span>
</pre>

                              <div class="method-source-code" id="normalize-source">
            <pre><span class="ruby-comment"># File matrix-0.4.2/lib/matrix.rb, line 2396</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">normalize</span>
  <span class="ruby-identifier">n</span> = <span class="ruby-identifier">magnitude</span>
  <span class="ruby-identifier">raise</span> <span class="ruby-constant">ZeroVectorError</span>, <span class="ruby-string">&quot;Zero vectors can not be normalized&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">n</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
  <span class="ruby-keyword">self</span> <span class="ruby-operator">/</span> <span class="ruby-identifier">n</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-r" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">r</span><span
                                class="method-args">()</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="Vector.html#method-i-magnitude">magnitude</a>
                            </div>
                          </div>

                  <div id="method-i-round" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">round</span><span
                                class="method-args">(ndigits=0)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns a vector with entries rounded to the given precision (see Float#round)</p>

                              <div class="method-source-code" id="round-source">
            <pre><span class="ruby-comment"># File matrix-0.4.2/lib/matrix.rb, line 2082</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">round</span>(<span class="ruby-identifier">ndigits</span>=<span class="ruby-value">0</span>)
  <span class="ruby-identifier">map</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">round</span>(<span class="ruby-identifier">ndigits</span>)}
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-size" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">size</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the number of elements in the vector.</p>

                              <div class="method-source-code" id="size-source">
            <pre><span class="ruby-comment"># File matrix-0.4.2/lib/matrix.rb, line 2089</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">size</span>
  <span class="ruby-ivar">@elements</span>.<span class="ruby-identifier">size</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-to_a" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">to_a</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the elements of the vector in an array.</p>

                              <div class="method-source-code" id="to_a-source">
            <pre><span class="ruby-comment"># File matrix-0.4.2/lib/matrix.rb, line 2434</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">to_a</span>
  <span class="ruby-ivar">@elements</span>.<span class="ruby-identifier">dup</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-to_matrix" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">to_matrix</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Return a single-column matrix from this vector</p>

                              <div class="method-source-code" id="to_matrix-source">
            <pre><span class="ruby-comment"># File matrix-0.4.2/lib/matrix.rb, line 2441</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">to_matrix</span>
  <span class="ruby-constant">Matrix</span>.<span class="ruby-identifier">column_vector</span>(<span class="ruby-keyword">self</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-to_s" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">to_s</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Overrides Object#to_s</p>

                              <div class="method-source-code" id="to_s-source">
            <pre><span class="ruby-comment"># File matrix-0.4.2/lib/matrix.rb, line 2483</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">to_s</span>
  <span class="ruby-string">&quot;Vector[&quot;</span> <span class="ruby-operator">+</span> <span class="ruby-ivar">@elements</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">&quot;, &quot;</span>) <span class="ruby-operator">+</span> <span class="ruby-string">&quot;]&quot;</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-zero-3F" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">zero?</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns whether all elements are zero.</p>

                              <div class="method-source-code" id="zero-3F-source">
            <pre><span class="ruby-comment"># File matrix-0.4.2/lib/matrix.rb, line 2170</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">zero?</span>
  <span class="ruby-identifier">all?</span>(<span class="ruby-operator">&amp;</span><span class="ruby-value">:zero?</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="private-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Private Instance Methods</h3>
                </header>

                  <div id="method-i-initialize_copy" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">initialize_copy</span><span
                                class="method-args">(v)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Called for dup &amp; clone.</p>
                                <div class="method-calls-super">
                                  Calls superclass method
                                  
                              </div>

                              <div class="method-source-code" id="initialize_copy-source">
            <pre><span class="ruby-comment"># File matrix-0.4.2/lib/matrix.rb, line 2185</span>
        <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize_copy</span>(<span class="ruby-identifier">v</span>)
  <span class="ruby-keyword">super</span>
  <span class="ruby-ivar">@elements</span> = <span class="ruby-ivar">@elements</span>.<span class="ruby-identifier">dup</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">frozen?</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-set_component" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">set_component</span><span
                                class="method-args">(i, v)</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="Vector.html#method-i-5B-5D-3D">[]=</a>
                            </div>
                          </div>

                  <div id="method-i-set_element" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">set_element</span><span
                                class="method-args">(i, v)</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="Vector.html#method-i-5B-5D-3D">[]=</a>
                            </div>
                          </div>

                  <div id="method-i-set_range" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">set_range</span><span
                                class="method-args">(range, value)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="set_range-source">
            <pre><span class="ruby-comment"># File matrix-0.4.2/lib/matrix.rb, line 2067</span>
        <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">set_range</span>(<span class="ruby-identifier">range</span>, <span class="ruby-identifier">value</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Vector</span>)
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-string">&quot;vector to be set has wrong size&quot;</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">range</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">size</span>
    <span class="ruby-ivar">@elements</span>[<span class="ruby-identifier">range</span>] = <span class="ruby-identifier">value</span>.<span class="ruby-identifier">elements</span>
  <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Matrix</span>)
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">ErrDimensionMismatch</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">row_count</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span>
    <span class="ruby-ivar">@elements</span>[<span class="ruby-identifier">range</span>] = <span class="ruby-identifier">value</span>.<span class="ruby-identifier">row</span>(<span class="ruby-value">0</span>).<span class="ruby-identifier">elements</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-ivar">@elements</span>[<span class="ruby-identifier">range</span>] = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">range</span>.<span class="ruby-identifier">size</span>, <span class="ruby-identifier">value</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-set_value" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">set_value</span><span
                                class="method-args">(index, value)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="set_value-source">
            <pre><span class="ruby-comment"># File matrix-0.4.2/lib/matrix.rb, line 2063</span>
        <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">set_value</span>(<span class="ruby-identifier">index</span>, <span class="ruby-identifier">value</span>)
  <span class="ruby-ivar">@elements</span>[<span class="ruby-identifier">index</span>] = <span class="ruby-identifier">value</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is provided by <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>. </p><p><a href="https://jamesbritt.bandcamp.com/">Hack your world.  Feed your head.  Live curious</a>.</p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

